< previous page page_41 next page >

Page 41
As you can see in Figure 3.1, a Visual Basic form contains all the elements you would expect to find as part of a window in a program. It contains a title bar, a control menu, and a set of Minimize, Maximize/Restore, and Close buttons. Note that many of these elements, such as the Close button, are always present at design time even if the properties are set in such a way that they are not visible at runtime.
Another design-time feature is a grid of dots that allows you to line up controls easily as you are designing your interface. You can control the behavior of the design grid through the Options dialog box, which you can access by choosing Tools, Options from the menu system. In this dialog box, you can change the size of the grid or even turn it off completely. You can also choose whether controls are automatically aligned to the grid. If this option is on (the default setting), the upper-left corner of each control is aligned with the grid point that's closest to the corner. Using the default setting enables you to line up controls easily. In fact, I set the grid to be smaller than the default, which allows more precise control alignment.
What Do Forms Do?
As I mentioned earlier, forms represent your program's user interface. That is, forms are what your users see and interact with. All the controls that users work with, such as text boxes, command buttons, and so forth, are contained on one or more forms.
In addition to serving as containers for controls, forms act as a sort of overall "traffic cop" overseeing the use of the objects that make up the interface. You'll see many examples of using program code to respond to events that occur to various objects. All the program code that relates to the objects on a particular form is stored (and edited) as a part of the form itself. In other words, the form contains not only the objects the users can see, but it also contains the program code that the users can't see.
Using Controls
Although forms are an important part of your programs, you can't do very much without adding controls to them. Visual Basic controls let you perform a wide variety of tasks including editing text, displaying pictures, and interfacing with a database. The liberal use of controls has always been one of Visual Basic's strongest features.
What Are Controls?
In Visual Basic, controls are objects designed to perform specific tasks. Like form objects, controls have associated properties, events, and methods. For example, if you use a TextBox control, you can set properties to determine the size of the text box, the font for the text that it displays, and the color of the text and background.
Because of Visual Basic's design, you are not limited to using only the controls provided by Microsoft. The design allows easy integration of third-party controlswhich has led to a thriving market for these custom controls. With this amount of third-party involvement, chances are that you can find a control to perform almost any task you want, from data acquisition to custom reporting to specialized graphics processing to game play, and everything in between.

 
< previous page page_41 next page >